<%-- 
    Document   : addMagAction
    Created on : Feb 25, 2012, 3:17:40 AM
    Author     : Hiroroi
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@page import="java.sql.*, DBConnection.*, UserPackage.*" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
            String magTitle, magDate, synopsis, price;
            boolean result;
            int magVol, magIssue;
            
            magTitle = request.getParameter("magTitle");
            magDate = request.getParameter("magDate");
            magVol = Integer.parseInt(request.getParameter("magVol"));
            magIssue = Integer.parseInt(request.getParameter("magIssue"));
            synopsis = request.getParameter("synopsis");
            price = request.getParameter("price");
            
            magTitle = magTitle.replaceAll("[^a-zA-Z0-9@._]", "");
            magDate = magDate.replaceAll("[^a-zA-Z0-9@._-]", "");
            

            Product newMag = new Product();
            
            newMag.setMagTitle(magTitle);
            newMag.setMagDate(magDate);
            newMag.setMagVolNo(magVol);
            newMag.setMagIssueNo(magIssue);
            newMag.setSynopsis(synopsis); 
            newMag.setPrice(price); 
            
            result = new ProductManager().addMag(newMag);
            
            if(result == true)
                response.sendRedirect("addMag.jsp");
            else
                response.sendRedirect("prodMgrHomePage.jsp");
          %>
    </body>
</html>
